package com.egreen.pointsmall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.egreen.common.pojo.entity.pointsmall.Product;
import com.egreen.pointsmall.service.IProductService;

import com.egreen.pointsmall.dao.ProductDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品表 服务实现类
 * </p>
 *
 * @author yyf
 * @since 2023-04-05
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductDao, Product> implements IProductService {
    @Autowired
    private ProductDao productDao;

    @Override
    public List<Product> findAllByTypeAndProduct(Integer type, Integer ProductCategoryId) {
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        String column=null;
        switch (type) {
            case 1:
                column="categorylevelone_id";
                break;
            case 2:
                column="categoryleveltwo_id";
                break;
            case 3:
                column="categorylevelthree_id";
                break;
        }
        queryWrapper.eq(column,ProductCategoryId);
        List<Product> products = productDao.selectList(queryWrapper);
        return products;
    }
}
